//
//  DJFeedbackListCell.m
//  YogoVideo
//
//  Created by tikeios_002 on 2024/1/16.
//

#import "DJFeedbackListCell.h"
#import "DJFeedbackListImageCell.h"
#import "SYCollectionViewRoundFlowLayout.h"

@implementation DJFeedbackListCell
{
    NSArray * imageArr;
    CGFloat itemW;
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
    [self addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    itemW = (KScreen_W-118)/3-0.2;
    UIImageView * showTextViewImgTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 60, 60)];
    showTextViewImgTo2.hidden = YES;
    showTextViewImgTo2.layer.cornerRadius = K_AUTOLAYOUT_W(30);
    showTextViewImgTo2.clipsToBounds = YES;
    showTextViewImgTo2.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:showTextViewImgTo2];
    
    UILabel * showTextViewLabelTo2 = [[UILabel alloc]initWithFrame:CGRectMake(15, 35, KScreen_W-30, 30)];
    showTextViewLabelTo2.hidden = YES;
    showTextViewLabelTo2.font = FontBold(18);
    showTextViewLabelTo2.textColor = ThreeColor;
    showTextViewLabelTo2.textAlignment = NSTextAlignmentCenter;
    [self addSubview:showTextViewLabelTo2];
    // Initialization code
    [self.imageCollection registerNib:[UINib nibWithNibName:@"DJFeedbackListImageCell" bundle:nil] forCellWithReuseIdentifier:@"DJFeedbackListImageCell"];
    self.imageCollection.delegate = self;
    self.imageCollection.dataSource = self;
    SYCollectionViewRoundFlowLayout *layout = (SYCollectionViewRoundFlowLayout *)self.imageCollection.collectionViewLayout;
    layout.sectionHeadersPinToVisibleBounds = YES;
    layout.collectionCellAlignmentType = SYCollectionViewFlowLayoutAlignmentTypeByLeft;
    
    UIView * QZTestTo6 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    QZTestTo6.clipsToBounds = YES;
    [self addSubview:QZTestTo6];
    UILabel * QZTestTo7 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger  QZTestTo8 = arc4random_uniform(20);
    NSLog(@"随机数：%ld", (long) QZTestTo8);
    QZTestTo7.text = [NSString stringWithFormat:@"%ld",(long)QZTestTo8];
    [QZTestTo6 addSubview:QZTestTo7];
    
    UIButton * QZTestTo12 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    NSString * QZTestTo13 = @"agadsgads";
    [QZTestTo12 setTitle:QZTestTo13 forState:UIControlStateNormal];
    
    UILabel * keyLabel = [[UILabel alloc] init];
    keyLabel.textColor = [UIColor grayColor];
    keyLabel.text = @"key";
    keyLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:keyLabel];
    
    UILabel * valueLabel = [[UILabel alloc] init];
    valueLabel.textColor = [UIColor grayColor];
    valueLabel.text = @"value";
    valueLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:valueLabel];
    
    UITextView * keyTextView1 = [[UITextView alloc] init];
    keyTextView1.backgroundColor = [UIColor whiteColor];
    keyTextView1.font = [UIFont systemFontOfSize:17];
    keyTextView1.layer.borderColor = [UIColor grayColor].CGColor;
    keyTextView1.layer.borderWidth = 1.0f;
    keyTextView1.layer.cornerRadius = 6.0f;
    [self addSubview:keyTextView1];
    
    UITextView * valueTextView1 = [[UITextView alloc] init];
    valueTextView1.backgroundColor = [UIColor whiteColor];
    valueTextView1.font = [UIFont systemFontOfSize:17];
    valueTextView1.layer.borderColor = [UIColor grayColor].CGColor;
    valueTextView1.layer.borderWidth = 1.0f;
    valueTextView1.layer.cornerRadius = 6.0f;
    [self addSubview:valueTextView1];
    
    UITextView * keyTextView2 = [[UITextView alloc] init];
    keyTextView2.backgroundColor = [UIColor whiteColor];
    keyTextView2.font = [UIFont systemFontOfSize:17];
    keyTextView2.layer.borderColor = [UIColor grayColor].CGColor;
    keyTextView2.layer.borderWidth = 1.0f;
    keyTextView2.layer.cornerRadius = 6.0f;
    [self addSubview:keyTextView2];
    
    self.showView.backgroundColor = subviewback_black;
    self.showView.layer.cornerRadius = 12;
    self.showView.clipsToBounds = YES;
    self.tipView.layer.cornerRadius = 4;
    self.tipView.clipsToBounds = YES;
    self.userImage.layer.cornerRadius = 18;
    self.userImage.clipsToBounds = YES;
    self.userImage.layer.borderWidth = 1.5;
    self.userImage.layer.borderColor = UIColor.whiteColor.CGColor;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)showConfig:(NSDictionary *)dic{
    if([dic[@"type"] isEqualToString:@"回复反馈"]){
        self.userImage.image = KImageNamed(@"ico_logo");
    }else{
        [self.userImage sd_setImageWithURL:KUrlString([QZUserInfoModel share].image) placeholderImage:KImageNamed(@"ic_head_defuls")];
    }
    if(![dic[@"reply_look"] boolValue]){
        self.tipView.hidden = NO;
        self.tipView.backgroundColor = MainColor;
    }else{
        self.tipView.hidden = YES;
    }
    self.contentLabel.text = dic[@"content"];
    self.timeLabel.text = dic[@"createtime"];
    imageArr = dic[@"images"];
    if([imageArr count] > 0){
        self.imageTop.constant = 8;
        self.imageHeight.constant = itemW;
    }else{
        self.imageTop.constant = -8;
        self.imageHeight.constant = 0;
    }
    [self.imageCollection reloadData];
}
#pragma mark - collectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return imageArr.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    DJFeedbackListImageCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DJFeedbackListImageCell" forIndexPath:indexPath];
    [cell.imageView sd_setImageWithURL:KUrlString(imageArr[indexPath.row])];
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(itemW, itemW);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 10;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 10;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
    
}
- (void)showTextViewSubViewToViewTo2:(UIView * )subView{

    UIView * showTextViewSubViewTo2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewSubViewTo2.clipsToBounds = YES;
    [subView addSubview:showTextViewSubViewTo2];
    UILabel * showTextViewSubViewLabelTo3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    showTextViewSubViewLabelTo3.text = @"ppppp88888";
    [showTextViewSubViewTo2 addSubview:showTextViewSubViewLabelTo3];
    
    UIImageView * showTextViewSubViewTo3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [subView addSubview:showTextViewSubViewTo3];

}
@end
